package com.lxp.eduService.controller;


import com.lxp.eduService.client.VodClient;
import com.lxp.eduService.domain.EduVideo;
import com.lxp.eduService.service.impl.EduVideoServiceImpl;
import com.lxp.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author lxp
 * @since 2021-11-20
 */

//小节控制器
@RestController
@RequestMapping("/eduService/edu-video")

public class EduVideoController {
    @Autowired
    private EduVideoServiceImpl service;

    //添加小节
    @PostMapping("/addVideo")
    public R addVideo(@RequestBody EduVideo video){
        boolean flag = service.save(video);
        if (flag){
            return R.ok();
        }
        return R.error().message("网络异常");
    }

    //修改小节
    @PostMapping("/updateVideo")
    public R updateVideo(@RequestBody EduVideo video){
        boolean flag = service.updateById(video);
        if (flag){
            return R.ok();
        }
        return R.error().message("网络异常");
    }

    //查询小节
    @GetMapping("/findVideoById/{videoId}")
    public R findVideoById(@PathVariable String videoId){
        EduVideo video = service.getById(videoId);
        return R.ok().data("video",video);
    }

    //删除小节
    @DeleteMapping("{videoId}")
    public R deleteVideoById(@PathVariable String videoId){
        service.removeVideo(videoId);
        return R.ok();
    }


}

